package org.fuys.coder.common.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @projectName: fuys-low-coder
 * @package: org.fuys.coder.common
 * @className: Result
 * @author: WangJing
 * @description: 应用层返回结果
 * @date: 2024/6/18 20:56
 * @version: 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private String msg;
    private Object data;
    private Exception exception;
    private int code;
    public static Result error(String msg){
        Result result=new Result();
        result.setMsg(msg);
        return result;
    }

    public static Result ok(){
        Result result=new Result();
        //todo 考虑添加一个枚举类
        result.setCode(200);
        return result;
    }

    public Result msg(String msg){
        this.msg=msg;
        return this;
    }

    public Result data(Object data){
        this.data=data;
        return this;
    }

    public Result exception(Exception e){
        this.exception=e;
        return this;
    }

    public Result code(int code){
        this.code=code;
        return this;
    }

}
